<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core">   

    <h:head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    </h:head>

    <h:body>

        <ui:composition>

            <p:dialog closable="true" showHeader="true" widgetVar="pn_pesquisa_enderecos" resizable="false" width="800"
                      maximizable="false" modal="true" styleClass="dialog" appendToBody="true">

                <f:facet name="header">
                    #{msg.pontoInteresse_Titulo_Painel}
                </f:facet>

                <h:form id="frm_pesquisa_enderecos">

                    <p:messages id="msg_pesquisa_enderecos" closable="true" autoUpdate="false" escape="false"/>

                    <p:fieldset>

                        <h:panelGrid columns="2" cellspacing="2" cellpadding="2">

                            <p:outputLabel for="itEndereco" value="#{msg.pontoInteresse_digite_endereco}: "/>

                            <h:panelGrid columns="2">
                                <p:inputText id="itEndereco" value="#{controllerAddPontosInteresse.paramPesquisa}" style="width: 40em">
                                </p:inputText>
                                <p:commandButton id="btPesquisarEnd" value="Pesquisar" action="#{controllerAddPontosInteresse.pesquisarEnderecos}" process="@form" update="opEndEncontrados" type="submit"/>
                            </h:panelGrid>

                        </h:panelGrid>

                        <p:outputPanel id="opEndEncontrados">

                            <p:dataTable id="dtEndEncontrados"
                                         value="#{controllerAddPontosInteresse.resultadosPesquisa}"
                                         var="result"
                                         emptyMessage="Nenhum Endereço Encontrado">

                                <p:column headerText="Endereços Encontrados" style="width: 90%">
                                    #{result.formatted_address}
                                </p:column>

                                <p:column headerText="Opções" style="width: 10%; text-align: center">
                                    <p:commandButton id="btMaps" icon="ui-icon-globe" title="Visualizar No Mapa" action="#{controllerPrincipal.adicionarMarcadorOcorrencia(result)}" update=":frm_global:spMaps, :frm_global:tav_view_menu:spOcorrencias" oncomplete="pn_pesquisa_enderecos.hide(); abrirPainelOcorrencias(#{controllerPrincipal.indiceSelecionado}); #{executeOnComplete}"/>
                                </p:column>

                            </p:dataTable>

                        </p:outputPanel>                        

                    </p:fieldset>

                    <div class="espacamento"/>

                    <div align="left">

                        <p:commandButton id="btFechar"
                                         icon="ui-icon-close"
                                         value="#{msg.fechar}"
                                         immediate="true"
                                         onclick="pn_pesquisa_enderecos.hide();"/>

                    </div>

                </h:form>

            </p:dialog>

        </ui:composition>

    </h:body>

</html>
